package com.muyu.danmo.controller;


import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.danmo.domain.DanmoInformationPositions;
import com.muyu.danmo.service.IDanmoInformationPositionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 职位Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/danmoInformationPositions")
public class DanmoInformationPositionsController extends BaseController
{
    @Autowired
    private IDanmoInformationPositionsService danmoInformationPositionsService;

    /**
     * 查询职位列表
     */
//    @RequiresPermissions("system:danmoInformationPositions:list")
    @PostMapping("/ldist")
    public Result<List<DanmoInformationPositions>> list(@RequestBody DanmoInformationPositions danmoInformationPositions)
    {

        List<DanmoInformationPositions> list = danmoInformationPositionsService.selectDanmoInformationPositionsList(danmoInformationPositions);
        return Result.success(list);
    }

    /**
     * 导出职位列表
     */
//    @RequiresPermissions("system:danmoInformationPositions:export")
    @Log(title = "职位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DanmoInformationPositions danmoInformationPositions)
    {
        List<DanmoInformationPositions> list = danmoInformationPositionsService.selectDanmoInformationPositionsList(danmoInformationPositions);
        ExcelUtil<DanmoInformationPositions> util = new ExcelUtil<DanmoInformationPositions>(DanmoInformationPositions.class);
        util.exportExcel(response, list, "职位数据");
    }

    /**
     * 获取职位详细信息
     */
//    @RequiresPermissions("system:danmoInformationPositions:query")
    @GetMapping(value = "/{positionId}")
    public Result getInfo(@PathVariable("positionId") Long positionId)
    {
        return success(danmoInformationPositionsService.selectDanmoInformationPositionsByPositionId(positionId));
    }

    /**
     * 新增职位
     */
//    @RequiresPermissions("system:danmoInformationPositions:add")
    @Log(title = "职位", businessType = BusinessType.INSERT)
    @PostMapping
    public Result add(@RequestBody DanmoInformationPositions danmoInformationPositions)
    {
        return toAjax(danmoInformationPositionsService.insertDanmoInformationPositions(danmoInformationPositions));
    }

    /**
     * 修改职位
     */
//    @RequiresPermissions("system:danmoInformationPositions:edit")
    @Log(title = "职位", businessType = BusinessType.UPDATE)
    @PutMapping
    public Result edit(@RequestBody DanmoInformationPositions danmoInformationPositions)
    {
        return toAjax(danmoInformationPositionsService.updateDanmoInformationPositions(danmoInformationPositions));
    }

    /**
     * 删除职位
     */
//    @RequiresPermissions("system:danmoInformationPositions:remove")
    @Log(title = "职位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{positionIds}")
    public Result remove(@PathVariable Long[] positionIds)
    {
        return toAjax(danmoInformationPositionsService.deleteDanmoInformationPositionsByPositionIds(positionIds));
    }
}
